﻿<!DOCTYPE html>
<html>
<head>
    <title>曝光台</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>


</head>
<body>
<style>
    .new_serach{
        margin: 10px 0px;
        padding: 15px 15px;
        background-color: #fff;
        display: inline-block;
        width: 100%;
    }
    .new_serach .layui-btn{height: 38px;line-height: 38px;margin-bottom:5px;}
    .new_serach .layui-input{
        height:38px!important;
        line-height:38px!important;

    }
</style>
<div class="newtest">

    <div class=" new_serach">
        <form class="layui-form layui-form-pane layui-col-md12 x-so" name="searchForm">
            <div class="layui-inline mb-10" >
                <label class="layui-form-label">项目名称</label>
                <div class="layui-input-inline wd-140">
                    <input class="layui-input" name="keyword" value=""  autocomplete="off">
                </div>
            </div>

            <div class="layui-inline mb-10" >
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline wd-140">
                    <select name="exposureAuto">
                        <option value="0">全部</option>
                        <option value="1">未移除</option>
                        <option value="2">移除</option>
                    </select>
                </div>
            </div>

            <input type="hidden" name="istype" value="{$istype}">
            <div class="layui-inline mb-10" >
                <button class="layui-btn serach_btn" type="button" ><i class="layui-icon">&#xe615;</i></button>
                <button class="layui-btn layui-btn-primary" type="reset">重置</button>
            </div>
        </form>
    </div>

    <!--导入按钮-->
    <button type="button" class="layui-btn-sm layui-btn" id="test3" lay-event="upload" style="display: none" ></button>

    <div class="new_main">

<!--        <script type="text/html" id="toolbarDemo">-->
<!--            <div class="layui-btn-container">-->
<!--                <a class="layui-btn-sm layui-btn layui-btn-danger" lay-event="getCheckLength">批量删除</a>-->
<!--            </div>-->
<!--        </script>-->

        <script type="text/html" id="title">
            <a style="color: #0b6fff" lay-event="title" >{{d.title}}</a>
        </script>

        <table class="layui-hide" id="demo" lay-filter="demo"></table>

        <script type="text/html" id="switchTpl">
            <!--启用禁用操作-->
            <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="sexDemo" {{ d.status == 1 ? 'checked' : '' }}>
        </script>


        <script type="text/html" id="exposureAuto">
            {{#  if(d.exposureAuto==0){ }}
            未移除
            {{#  } else { }}
            移除
            {{#  } }}
        </script>

        <script type="text/html" id="overseerTpl">
            {{#  if(d.overseerCount>0){ }}
            <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="overseerList" data-val="2">督查概况</button>
            {{#  } else { }}
            <button class="layui-btn layui-btn-sm" lay-event="overseerList" data-val="2">督查概况</button>
            {{#  } }}
        </script>

        <script type="text/html" id="advanceTpl">
            {{#  if(d.advanceCount>0){ }}
            <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="advance">推进计划</button>
            {{#  } else { }}
            <button class="layui-btn layui-btn-sm" lay-event="advance">推进计划</button>
            {{#  } }}
        </script>

        <script type="text/html" id="barDemo">

            {if condition="$istype eq 1"}
            <button class="layui-btn layui-btn-sm" lay-event="edit">编辑</button>
            {/if}

            <button class="layui-btn layui-btn-sm" lay-event="detail">查看详情</button>
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</button>
        </script>

    </div>


</div>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<!--弹框js-->
<script src="/static/js/yii.js"></script>
<script>
    var modal=new yii.modal();
    layui.use(['form','jquery','layer','laydate','table','upload'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload;;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格

        var url = "{:URL('project/Exposure/index')}";
        var detail = "{:URL('project/Exposure/detail')}";

        //搜索操作
        $('.serach_btn').click(function () {
            var data=$("form[name='searchForm']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            var where = dataVal;
            search(table,url,where)
        });

        //列表
        var data=$("form[name='searchForm']").serializeArray();
        var dataVal = {type:'list'};
        $.each(data, function(i, item){
            dataVal[item.name] = item.value;
        });
        var where = dataVal;

        var title = "权限列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'title', title: '项目名称', align:'center',toolbar: '#title'}
            ,{field: 'libraryName', title: '所属库', align:'center'}
            ,{field: 'duty_unit', title: '责任单位', align:'center'}
            ,{field: 'exposureAuto', title: '状态', align:'center',toolbar: '#exposureAuto'}
            ,{field: 'operation', title: '督查概况 ', align:'center',toolbar: '#overseerTpl'}
        ]];

        var istype = {$istype};
        if(istype!=1){
            cols[0].push(
                {field: 'operation', title: '推进计划 ', align:'center',toolbar: '#advanceTpl'}
            );
        }


        cols[0].push(
            {field: 'addtime', title: '更新时间', align:'center',sort: true}
        );


        showlist(table,url,where,title,cols,0,10,'#demo','#toolbarDemo');
        $(".layui-laypage-skip").find("input").val(3 );
        $(".layui-laypage-btn").click();


        //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'title'://显示基本信息
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['800px', '65%'], //宽高
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,post
                        maxmin: true,
                        title: "基本信息",
                        content: "{:URL('project/Comment/basic')}?id="+id,
                        btn: ['关闭']
                    });
                    break;
                case 'overseerList': //督查概况
                    var showUrl = "{:URL('project/Overseer/index')}?id="+id;
                    overseerView(showUrl);
                    break;
                case 'advance':
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['1000px','900px'],            //宽度450px,高自适应
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,
                        maxmin: true,
                        title: obj.data.title+"推进计划",
                        content:"{:URL('project/advancePlan/index')}?id="+id,
                        btn:['通知责任人','取消'],
                        btn1: function (index,layero) {
                            $.ajax({
                                type:'post',
                                url:"{:URL('project/Communal/sendSms')}",
                                data:{id:id,operation:"planCareful"},
                                dataType:'JSON',
                                success:function (res) {
                                    layer.alert(res.msg);
                                },
                                error:function (res) {
                                }
                            });


                        },
                    });
                    break;
            }
        })


        //督查概况视图
        function overseerView(showUrl,title="督查概况"){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['80%','80%'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: title,
                content:showUrl,
                btn:['确定','取消'],
                yes: function (index) {
                    layer.close(index);
                },
            });
        }

        function showView(showUrl,type){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['700px','880px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: type,
                content:showUrl,
                btn:['确认','关闭'],
                yes: function (index,layero) {
                    var body = layer.getChildFrame('body', index);
                    var data = body.find("form[name='saveForm']").serializeArray();
                    // data.push({name: "plan_id", value: plan_id});
                    $.ajax({
                        type: "post",
                        url: "{:URL('project/help/save')}",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            layer.close(index);
                            table.reload("demo");
                        }
                    });
                },
            });
        }


        //头工具栏事件
        table.on('toolbar(demo)', function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'add':
                    var showUrl = "{:URL('project/help/addView')}";
                    showView(showUrl,"添加");
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }

                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/Exposure/del')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;
            }
        });


        layui.form.render('select');
    });
</script>
</body>
</html>
